#!/bin/bash

#    Encoding converter plugin for gedit application
#    Copyright (C) 2009  Alexey Kuznetsov <ak@axet.ru>
#    Copyright (C) 2011  Krzysztof Dryja <cih997@gmail.com>

#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.

#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.

#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.


# gedit plugin directory
DEST=/usr/lib/gedit/plugins/

# create it
mkdir -p ${DEST}

# remove previous verision (1.0.0) and currect version of plugin
rm -rf ${DEST}/gencodingconverter*

# install currect verion of plugin
cp -rv gencodingconverter* ${DEST}

# enable the plugin
NAME=gencodingconverter

LIST=$(gconftool-2 --get /apps/gedit-2/plugins/active-plugins)
LIST=${LIST/[/}
LIST=${LIST/]/}

if [[ ${LIST} != *${NAME}* ]]
then
  LIST=${NAME},${LIST}
fi

gconftool-2 -t list --list-type=string --set /apps/gedit-2/plugins/active-plugins [${LIST}]
